﻿using Frameworks;
using Newtonsoft.Json.Linq;
using UnityEngine;

namespace Networks.Handlers
{
    public class GameHandler
    {
        public static void onAdd(JObject data)
        {
            //Debug.Log("onAdd-: " + data);
            EventProxy.BroadcastEvent(Routes.LOBBY_NOTIFY_ADD, data);
        }

        public static void onLeave(JObject data)
        {
            //Debug.Log("onLeave-: " + data);
            EventProxy.BroadcastEvent(Routes.LOBBY_NOTIFY_LEAVE, data);
        }

        // 收到消息
        public static void onChat(JObject data)
        {
            //Debug.Log("onChat-: " + data);
            EventProxy.BroadcastEvent(Routes.LOBBY_NOTIFY_CHAT, data);
        }

        // 发送消息的回调
        public static void onRespSendChat(JObject data)
        {
            //Debug.Log("onSendChat-: " + data);
        }

        //----------------------------------------------------------
        // 请求房间列表
        public static void onRespRoomList(JObject data)
        {
            //Debug.Log("onRespRoomList-: " + data);
            EventProxy.BroadcastEvent(Routes.ROOM_LIST, data);
        }

        // 创建房间
        public static void onRespCreateRoom(JObject data)
        {
            Debug.Log("onRespCreateRoom-: " + data);
            EventProxy.BroadcastEvent(Routes.ROOM_CREATE, data);
        }

        // 加入房间
        public static void onRespJoinRoom(JObject data)
        {
            //Debug.Log("onRespJoinRoom-: " + data);
            EventProxy.BroadcastEvent(Routes.ROOM_JOIN, data);
        }

        // 离开房间
        public static void onRespLeaveRoom(JObject data)
        {
            //Debug.Log("onRespLeaveRoom-: " + data);
            EventProxy.BroadcastEvent(Routes.ROOM_LEAVE, data);
        }

        // 玩家动作 准备等
        public static void onRespPlayerAction(JObject data)
        {
            //Debug.Log("onRespPlayerAction-: " + data);
            EventProxy.BroadcastEvent(Routes.ROOM_PLAYER_ACTION, data);
        }

        // --------------通知-----------
        public static void onRoomStateChange(JObject data)
        {
            Debug.Log("onRoomStateChange-: " + data);
            EventProxy.BroadcastEvent(Routes.ROOM_NOTIFY_STATE_CHANGFE, data);
        }

        public static void onPlayerLeave(JObject data)
        {
            //Debug.Log("onPlayerLeave-: " + data);
            EventProxy.BroadcastEvent(Routes.ROOM_NOTIFY_PLAYER_LEAVE, data);
        }

        public static void updatePlayerInfo(JObject data)
        {
            Debug.Log("updatePlayerInfo-: " + data);
            EventProxy.BroadcastEvent(Routes.ROOM_NOTIFY_PLAYER_INFO, data);
        }

        public static void updatePlayerState(JObject data)
        {
            Debug.Log("updatePlayerState-: " + data);
            EventProxy.BroadcastEvent(Routes.ROOM_NOTIFY_PLAYER_STATE, data);
        }

        public static void onRespStartGame(JObject data)
        {
            //Debug.Log("onRespStartGame-: " + data);
            EventProxy.BroadcastEvent(Routes.C2S_GAME_START, data);
        }

        // --------------Game-----------
        public static void onGameLoading(JObject data)
        {
            //Debug.Log("onGameLoading-: " + data);
            EventProxy.BroadcastEvent(Routes.S2C_GAME_LOAD, data);
        }

        public static void onGameBegin(JObject data)
        {
            //Debug.Log("onGameBegin-: " + data);
            EventProxy.BroadcastEvent(Routes.S2C_GAME_BEGIN, data);
        }

        // --------------Player-----------

        public static void onEnterFrame(JObject data)
        {
            //Debug.Log("onEnterFrame-: " + data);
            EventProxy.BroadcastEvent(Routes.GAME_NOTIFY_ENTER_FRAME, data);
        }
    }
}